function [] = write(po, coordinateType)
%WRITE Summary of this function goes here
%   Detailed explanation goes here
if nargin == 1
  coordinateType(1) = 'C';
end
  
if coordinateType(1) == 'D'
  fid = fopen('POSCAR', 'wt');
  fprintf(fid, [po.Name, '\n']);
  fprintf(fid, [num2str(po.LatticeConstant), ' \n']);
  fprintf(fid, [num2str(po.LatticeVectors(1, :)), ' \n']);
  fprintf(fid, [num2str(po.LatticeVectors(2, :)), ' \n']);
  fprintf(fid, [num2str(po.LatticeVectors(3, :)), ' \n']);
  for i = 1:size(po.AtomsPerAtomicSpecies, 1)
    fprintf(fid, [num2str(po.AtomsPerAtomicSpecies(i)), ' ']);
  end
  fprintf(fid, ' \n');

  fprintf(fid, 'Direct \n');
  for i = 1:size(po.DirectCoordinates, 1)
    fprintf(fid, [num2str(po.DirectCoordinates(i, :)), ' \n']);
  end

  fclose(fid);

  
else

  fid = fopen('POSCAR', 'wt');
  fprintf(fid, [po.Name, '\n']);
  fprintf(fid, [num2str(po.LatticeConstant), ' \n']);
  fprintf(fid, [num2str(po.LatticeVectors(1, :)), ' \n']);
  fprintf(fid, [num2str(po.LatticeVectors(2, :)), ' \n']);
  fprintf(fid, [num2str(po.LatticeVectors(3, :)), ' \n']);
  for i = 1:size(po.AtomsPerAtomicSpecies, 1)
    fprintf(fid, [num2str(po.AtomsPerAtomicSpecies(i)), ' ']);
  end
  fprintf(fid, ' \n');
  
  fprintf(fid, [num2str(po.CoordinatesType), ' \n']);
  for i = 1:size(po.PositionCoordinates, 1)
    fprintf(fid, [num2str(po.PositionCoordinates(i, :)), ' \n']);
  end
  
  fclose(fid);
end

end

